<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yak\layui\widgets\grid;

use yii\helpers\ArrayHelper;

class DataColumn extends \yii\grid\DataColumn implements LayuiColInterface
{
    /**
     * @param mixed $model
     * @param mixed $key
     * @param int $index
     * @return string
     */
    public function renderDataCell($model, $key, $index)
    {
        return $this->renderDataCellContent($model, $key, $index);
    }

    public function generateCol(): array
    {
        // TODO: Implement generateCol() method.
        $colOptions = ArrayHelper::getValue($this->options, 'colOptions', []);
        $colOptions['field'] = $this->attribute;
        $colOptions['title'] = $this->getHeaderCellLabel();
        return $colOptions;
    }

    public function getLabel(): string
    {
        // TODO: Implement getLabel() method.
        return $this->getHeaderCellLabel();
    }
}
